package com.issoft.studentresitor.config;

import com.issoft.studentresitor.Interceptor.DemoInterceptor;
import com.issoft.studentresitor.Interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置类
 * @author ：GJH
 * @date ：Created in 2025/5/24 10:05
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private TokenInterceptor tokenInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")//拦截所有请求
                .excludePathPatterns("/user/login")//放行登录接口
                .excludePathPatterns("/user/register")//放行注册接口
                .excludePathPatterns("/upload")//放行upload接口
                .excludePathPatterns("/student/fee/batchPay")
                .excludePathPatterns("/user/updatePassword")
                .excludePathPatterns("/doc.html")//放行 knife4j doc 页面
                .excludePathPatterns("/webjars/**");//放行 knife4j 静态资源
    }
}